<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>模版列表</title>
		<link rel="icon" href="favicon.ico" type="image/x-icon" />
		<jsp:include page="../include.jsp" />
		<c:set var="local" value="${pageContext.request.contextPath}/service/templateAction" scope="request"/>
		<script src="${local}/resource/swfupload/swfupload.js" type="text/javascript"></script>
		<script src="${local}/resource/swfupload/fileprogress.js" type="text/javascript"></script>
		<script src="${local}/resource/swfupload/handlers.js" type="text/javascript"></script>
		<link href="${local}/resource/swfupload/process.css" rel="stylesheet" type="text/css"/>
		<script type="text/javascript">
			var swfu;
			window.onload = function() {
				var settings = {
					flash_url : "${local}/resource/swfupload/swfupload.swf",
					upload_url: "upload.do",
					post_params: {"folder" : $("#tt").html()},
					file_size_limit : "100 MB",
					file_types : "*.*",
					file_types_description : "All Files",
					file_queue_limit : "0",
					custom_settings : {
						progressTarget : "fsUploadProgress",
						cancelButtonId : "btnCancel"
					},
					debug: false,
	
					// Button settings
					button_image_url: "${local}/resource/swfupload/button_notext.png",
					button_placeholder_id: "spanButtonPlaceHolder",
					button_text: "<span class='btnText'>上传文件</span>",
					button_width: 81,
					button_height: 24,
					button_text_top_padding: 2,
					button_text_left_padding: 20,
					button_text_style: '.btnText{color:#666666; cursor:pointer;}',
					
					// The event handler functions are defined in handlers.js
					file_queued_handler : fileQueued,
					file_queue_error_handler : fileQueueError,
					file_dialog_complete_handler : fileDialogComplete,
					upload_start_handler : uploadStart,
					upload_progress_handler : uploadProgress,
					upload_error_handler : uploadError,
					upload_success_handler : uploadSuccess,
					upload_complete_handler : uploadComplete2,
					queue_complete_handler : queueComplete	// Queue plugin event
				};
	
				swfu = new SWFUpload(settings);
				
				function uploadComplete2(numFilesUploaded) {
			    	location.href="list.do?folder="+$("#tt").html()+"&current="+$("#tt").html();
			     }
		     };
		     $(document).ready(function(){
		    	$("#up").click(function(){
		    		var folder=$("#tt").html();
		    		window.location='list.do?folder='+folder+'&up=1';
		    	});
		    	$("#asyn").click(function(){
		    		window.location='asyn.do?';
		    	});
		    });
		</script>
		<style>
			.file{
			    background-attachment: scroll;
			    background-color: transparent;
			    background-image: url("../resource/img/zTreeStandard.png");
			    background-repeat: no-repeat;
			    border: 0 none;
			    cursor: pointer;
			    height: 16px;
			    outline: medium none;
			    background-position: -78px -32px;
			    margin-right: 2px;
			    vertical-align: top;
			    vertical-align: middle;
			    width: 16px;
			}
			.folder{
			    background-attachment: scroll;
			    background-color: transparent;
			    background-image: url("../resource/img/zTreeStandard.png");
			    background-repeat: no-repeat;
			    border: 0 none;
			    cursor: pointer;
			    height: 16px;
			    outline: medium none;
			    background-position: -81px 0;
			    margin-right: 2px;
			    vertical-align: top;
			    vertical-align: middle;
			    width: 16px;
			}
		</style>
	</head>
	<body class="list">
		<div class="bar">
			<form action="create_folder.do" method="post">
				<label style="vertical-align:super;">当前目录:<span id="tt">${folder}</span></label>&nbsp;&nbsp;&nbsp;
				<span id="spanButtonPlaceHolder"></span>
				<input style="vertical-align:super;" id="btnCancel" type="button" value="取消" onclick="swfu.cancelQueue();" disabled="disabled" />
				&nbsp;&nbsp;&nbsp;
				<label style="vertical-align:super;">新建目录:</label>
				<input type="hidden" value="${folder}" name="path"/>
				<input style="vertical-align:super;" type="text" name="foldername" value="${pager.keyword}" size="10"/>
				<input style="vertical-align:super;" type="submit" id="searchButton" class="formButton" value="创建文件夹"/>
				<input style="vertical-align:super;" type="button" id="asyn" class="formButton" value="同 步"/>
				<c:if test="${realPath!=folder}">
					<input id="up" type="button" class="formButton" value="向 上" style="float: right; margin-right: 10px"/>
				</c:if>
			</form>
		</div>
		<div id="fsUploadProgress"></div>
		<div class="body">
			<form id="listForm" action="module.do" method="post">
				<table id="listTable" class="listTable">
					<tr>
						<th class="check">
							<input type="checkbox" class="allCheck"/>
						</th>
						<th>
							<a href="#" class="sort" name="domain" hidefocus>文件名</a>
						</th>
						<th>
							<a href="#" class="sort" name="siteName" hidefocus>大小</a>
						</th>
						<th>
							<a href="#" class="sort" name="path" hidefocus>修改时间</a>
						</th>
						<th>
							<span>操作</span>
						</th>
					</tr>
					<c:forEach items="${nodes}" var="node">
						<tr>
							<td>
								<input type="checkbox" name="ids" value="${node.id}"/>
							</td>
							<td>
								<c:set value="file" var="icon"/>
								<c:if test="${node.isParent}">
									<c:set value="folder" var="icon"/>
								</c:if>
								<button class="${icon}" type="button"></button>
								<c:choose>
									<c:when test="${node.isParent}">
										<a href="list.do?folder=${node.name}&current=${folder}">
											<span title="${node.name}">${node.name}</span>
										</a>
									</c:when>
									<c:otherwise>
										<span title="${node.name}">${node.name}</span>
									</c:otherwise>
								</c:choose>
							</td>
							<td>
								<fmt:formatNumber maxFractionDigits="3" value="${node.size}" type="number"/>KB
							</td>
							<td>
								${node.time}
							</td>
							<td>
								<a href="modify.do?id=${list.site_id}" title="重命名">[重命名]</a>
							</td>
						</tr>
					</c:forEach>
				</table>
					<c:choose>
						<c:when test="${fn:length(nodes)==0}">
							<div class="noRecord">没有找到任何记录!</div>
						</c:when>
						<c:otherwise>
							<div class="delete" style="padding-left: 10px">
								<input type="button" id="deleteButton" class="formButton" url="delete.do" value="删除" disabled hidefocus />
							</div>
						</c:otherwise>
					</c:choose>
			</form>
		</div>
	</body>
</html>